<template>
    <component :is="$myComponent"
               v-bind="$myProps"
               v-on="$myListeners"></component>
</template>

<script>
    export default {
        props: {
            componentName: String,
            component: [Function, Object]
        },
        computed: {
            //继承的属性
            $myProps () {
                let myProps = this.$public.inheritProps(this)

                this.$delete(myProps, 'componentName')
                this.$delete(myProps, 'component')

                return myProps
            },
            //继承的事件
            $myListeners () {
                return this.$public.inheritListeners(this)
            },
            //继承的组件
            $myComponent () {
                if (this.componentName) {
                    return () => import(this.componentName)
                } else {
                    return this.component
                }
            }
        }
    }
</script>